<!DOCTYPE html>
<meta charset="utf-8">
<title>Test Sample API when trial is enabled by script-added meta tag</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/origin-trials-helper.js"></script>
<script src="resources/origintrials.js"></script>
<script>

// TODO(iclelland): Generate this sample token during the build. The token
//   below will expire in 2033, but it would be better to always have a token which
//   is guaranteed to be valid when the tests are run. -->
// Generate these tokens with the given commands:
// generate_token.py http://127.0.0.1:8000 Frobulate --expire-timestamp=2000000000
var token = "AlCoOPbezqtrGMzSzbLQC4c+oPqO6yuioemcBPjgcXajF8jtmZr4B8tJRPAARPbsX6hDeVyXCKHzEJfpBXvZgQEAAABReyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiRnJvYnVsYXRlIiwgImV4cGlyeSI6IDIwMDAwMDAwMDB9";
// generate_token.py http://127.0.0.1:8000 FrobulateDeprecation --expire-timestamp=2000000000
var deprecation_token = "AvbKrs0bY/tHSwFK2lAKvf1yeXX/iQYYIedyDhtbuTkg9dQc3hJttUa2yP/YY6ojBXSZ6mJnd75H4v+T9YiJIg0AAABceyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiRnJvYnVsYXRlRGVwcmVjYXRpb24iLCAiZXhwaXJ5IjogMjAwMDAwMDAwMH0=";
// generate_token.py http://127.0.0.1:8000 FrobulateInvalidOS --expire-timestamp=2000000000
var invalid_os_token = "AtU8M1FWS2TbBCuG6ArIzseD6TBqls4fru1tJp4GyEMrvd+BgE14uWvstXek2Aw+iUjrl6QM5l/HZgpqEssvjgcAAABaeyJvcmlnaW4iOiAiaHR0cDovLzEyNy4wLjAuMTo4MDAwIiwgImZlYXR1cmUiOiAiRnJvYnVsYXRlSW52YWxpZE9TIiwgImV4cGlyeSI6IDIwMDAwMDAwMDB9";

// The trial is not enabled, as no token is provided.
//  - Skip the worker tests, as they will likely fail due to running after the
//    token is added below.
var skip_worker = true;
expect_failure(skip_worker);
expect_failure_bindings(' [disabled]');
expect_failure_deprecation(skip_worker);
expect_failure_implied(skip_worker);

// Add the token to enable the trial.
OriginTrialsHelper.add_token(token);
// Add the token to enable the deprecation trial.
OriginTrialsHelper.add_token(deprecation_token);
// Add the token for the trial with invalid OS.
OriginTrialsHelper.add_token(invalid_os_token);

// The trial is now enabled, by the token added via script.
expect_success();
expect_success_bindings();
expect_success_deprecation();
expect_success_implied();

// The trial should not be enabled for |FrobulateInvalidOS|
expect_failure_invalid_os();

</script>
